/**
 * 项目名：化工企业安全生产信息化管理平台
 * 日期：    2020-03-01 22:19:08
 * Copyright (c) 2015- -版权所有
 */

package com.joysuch.wwyt.edu.entity;

import static javax.persistence.GenerationType.IDENTITY;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EntityListeners;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;

import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.joysuch.wwyt.core.support.AutoSetCommonFieldListener;
import lombok.Data;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.SQLDeleteAll;
import org.hibernate.annotations.Where;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

@EntityListeners({ AuditingEntityListener.class, AutoSetCommonFieldListener.class })
@Entity
@Table(name = "wwyt_edu_exam_record")
@SQLDelete(sql = "update wwyt_edu_exam_record set DELETE_FLAG = '1' where id= ?")
@SQLDeleteAll(sql = "update wwyt_edu_exam_record set DELETE_FLAG = '1' where id= ?")
@Where(clause = "DELETE_FLAG = '0'")
@Data
@TableName(value = "wwyt_edu_exam_record")
public class EduExamRecord implements java.io.Serializable {

    private transient Integer joinCountActual;//实际参与考试数量
    private transient String jobName;//工作名称
    private transient Integer passCount;//通过考试的数量
    private transient Integer examCount;//应该参与的考试的数量
    private transient String passRate;//通过率
    private transient String departName;//部门名称

    // columns START
    @Id
    @GeneratedValue(strategy = IDENTITY)

    // ID
    @Column(name = "ID", unique = true, nullable = false)
    private Long id;

    // 考试ID
    @Column(name = "EXAM_ID")
    private Long examId;

    // 用户ID
    @Column(name = "USER_ID")
    private Long userId;

    // 分数
    @Column(name = "SCORE")
    private String score;

    // 试卷总分
    @Column(name = "TOTAL_SCORE")
    private Float totalScore;

    // 及格分
    @Column(name = "PASS_SCORE", length = 10)
    private Float passScore;

    // 评语
    @Column(name = "SUMMARY", length = 300)
    private String summary;

    // 交卷时间
    @Column(name = "SUBMIT_TIME")
    private java.util.Date submitTime;

    // 状态
    @Column(name = "STATE")
    private Integer state;

    // 创建人
    @org.springframework.data.annotation.CreatedBy
    @Column(name = "CREATE_BY")
    @JsonIgnore
    private Long createBy;

    // 创建时间
    @org.springframework.data.annotation.CreatedDate
    @Column(name = "CREATE_TIME")
    private java.util.Date createTime;

    // 更新人
    @org.springframework.data.annotation.LastModifiedBy
    @Column(name = "UPDATE_BY")
    @JsonIgnore
    private Long updateBy;

    // 更新时间
    @org.springframework.data.annotation.LastModifiedDate
    @Column(name = "UPDATE_TIME")
    @JsonIgnore
    private java.util.Date updateTime;

    // 删除标记
    @Column(name = "DELETE_FLAG", length = 2)
    @JsonIgnore
    private String deleteFlag;

    // 组织机构代码
    @Column(name = "ORG_CODE", length = 100)
    private String orgCode;

    // 租户
    @Column(name = "TENENT_ID")
    private Long tenentId;
    // columns END

    @Column(name = "SUBMIT_TIMES")
    private Integer submitTimes;

    @Column(name = "COST_TIME")
    private Long costTime;

    /**
     * 答对提数
     */
    @Column(name = "RIGHT_COUNT")
    private Integer rightCount;
    /***
     * 答错提数
     */
    @Column(name = "WRONG_COUNT")
    private Integer wrongCount;
    /**
     * 是否阅卷 0 不需要阅卷  1 未阅卷 2 已阅卷
     */
    @Column(name = "IS_CHECK")
    private Integer isCheck;

    /**
     * 签名
     */
    @Column(name = "autograph")
    private String autograph;

    @Column(name = "rotate_path")
    private String rotatePath;

    @Transient
    private transient String userName;

    public int hashCode() {
        return new HashCodeBuilder().append(getId()).toHashCode();
    }

    public boolean equals(Object obj) {
        if (obj instanceof EduExamRecord == false)
            return false;
        if (this == obj)
            return true;
        EduExamRecord other = (EduExamRecord) obj;
        return new EqualsBuilder().append(getId(), other.getId()).isEquals();
    }

    public EduExamRecord() {
    }

    public EduExamRecord(String score, String userName) {
        this.score = score;
        this.userName = userName;
    }

    public EduExamRecord(Long id, Long examId, Long userId, String score, Float totalScore, Float passScore,
            Date submitTime, Integer submitTimes, Integer state, String userName,Integer rightCount,Integer wrongCount) {
        super();
        this.id = id;
        this.examId = examId;
        this.userId = userId;
        this.score = score;
        this.totalScore = totalScore;
        this.passScore = passScore;
        this.submitTime = submitTime;
        this.submitTimes = submitTimes;
        this.userName = userName;
        this.state = state;
        this.rightCount = rightCount;
        this.wrongCount = wrongCount;
    }

}
